
# 导包
import pymysql


#创还数据库连接
conn=pymysql.connect(host='192.168.121.134',
                     port=3306,
                     user='root',
                     password='123456',
                     database='litemall',
                     charset='utf8'
                     )

#获取游标对象
cursor=conn.cursor()

#执行sql语句
try:
    sql="update litemall_keyword set keyword='父亲节' where id=1"
    cursor.execute(sql)

    # 提交事务
    conn.commit()
except Exception as e:
    # 回滚事务
    conn.rollback()
    print(e)
finally:
# 关闭游标和数据库连接
    cursor.close()
    conn.close()




